<template>
	<custom-page title="我的钱包" :float="true" background-color="#F9F9F9" nav-background-color="transparent" borderBottomColor="transparent">
		<template #page>
			<view class="page-content">
				<view class="top-bg">
					<view class="top-layout">
						<view class="title-row">
							<view class="title">我的资产（元）</view>
							<image class="safe-img" :src="asserts.ic_safety_green"></image>
							<view class="safe">安全保障中</view>
						</view>
						<view class="balance-row">
							<view class="balance">{{walletInfo.totalMoneyStr||0}}</view>
							<image @click="balanceTipsClick" :src="asserts.ic_question"></image>
						</view>
						<view class="bottom-layout" @click="mineOrderClick">
							<view class="item-balance">
								<view class="title">账户余额（元）</view>
								<view class="content">{{walletInfo.regularMoneyStr||0}}</view>
							</view>
							<!-- <view class="item-balance">
								<view class="title">提现中（元）</view>
								<view class="content">{{walletInfo.dislodgeAmount||0}}</view>
							</view> -->
							<view class="select">查看</view>
							<image class="select-img" :src="asserts.ic_arrow_right"></image>
						</view>
					</view>
				</view>
				<view class="btn-apply" @click="appplyWithdrawClick">申请提现</view>
				<view class="btn-order" @click="mineOrderClick">账单</view>
			</view>
		</template>
		<template #popup>
			<mine-wallet-popup ref="walletPopup"></mine-wallet-popup>
		</template>
	</custom-page>
</template>

<script>
	export default {
		data() {
			return {
				walletInfo: {},
			}
		},
		onLoad() {
			this.getBalanceInfo()
			
			//提现更新
			uni.$on('withdrawUpdate', this.getBalanceInfo)
		},
		onUnload() {
			uni.$off('withdrawUpdate', this.getBalanceInfo)
		},
		methods: {
			//我的钱包
			getBalanceInfo(){
				this.requestCenter.getBalanceInfo().then(res => {
					this.walletInfo = res
				})
			},
			
			balanceTipsClick(){
				this.$refs.walletPopup.show()
			},
			
			//申请提现
			appplyWithdrawClick(){
				uni.navigateTo({
					url: '/pages/withdrawal-apply/withdrawal-apply'
				})
			},
			
			//账单
			mineOrderClick(){
				uni.navigateTo({
					url: '/pages/mine-wallet-bill/mine-wallet-bill'
				})
			}
			
		}
	}
</script>

<style scoped lang="less">
	.page-content{
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
	}
	.top-bg{
		width: 100%;
		background: linear-gradient( 180deg, #D8F8FA 0%, #F9F9F9 100%);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}
	.top-layout{
		width: calc(100% - 64rpx);
		background: #FFFFFF;
		box-shadow: 0rpx 12rpx 24rpx 2rpx rgba(0,0,0,0.05);
		border-radius: 16rpx;
		padding: 32rpx 40rpx 0 40rpx;
		box-sizing: border-box;
		/* #ifdef H5 */
		margin: 120rpx 32rpx 0 32rpx;
		/* #endif */
		/* #ifndef H5 */
		margin: 220rpx 32rpx 0 32rpx;
		/* #endif */
		.title-row{
			display: flex;
			flex-direction: row;
			align-items: center;
			.title{
				flex: 1;
				font-size: 32rpx;
				color: #021624;
				line-height: 48rpx;
			}
			.safe{
				font-size: 24rpx;
				color: #04BC5C;
				line-height: 40rpx;
			}
			.safe-img{
				width: 28rpx;
				height: 32rpx;
				margin-right: 8rpx;
			}
		}
		.balance-row{
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-top: 20rpx;
			.balance{
				font-size: 56rpx;
				color: #01CBFF;
				line-height: 48rpx;
				flex: 1;
				font-weight: 500;
			}
			image{
				width: 32rpx;
				height: 32rpx;
			}
		}
		.bottom-layout{
			width: calc(100% + 64rpx);
			margin: 16rpx -32rpx 8rpx -32rpx;
			background: #F9F9F9;
			border-radius: 8rpx;
			padding: 20rpx 32rpx 20rpx 32rpx;
			box-sizing: border-box;
			display: flex;
			flex-direction: row;
			align-items: center;
			.item-balance{
				flex: 1;
				display: flex;
				flex-direction: column;
			}
			.title{
				font-size: 24rpx;
				color: #585F70;
				line-height: 48rpx;
			}
			.content{
				font-size: 28rpx;
				color: #585F70;
				font-weight: bold;
				margin-top: 4rpx;
			}
			.select{
				font-size: 28rpx;
				color: #585F70;
				line-height: 48rpx;
				margin-right: 18rpx;
			}
			.select-img{
				width: 20rpx;
				height: 20rpx;
			}
		}
	}
	.btn-apply{
		width: calc(100% - 64rpx);
		height: 100rpx;
		line-height: 100rpx;
		background: #01CBFF;
		box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(1,203,255,0.05);
		border-radius: 16rpx;
		font-size: 32rpx;
		color: #FFFFFF;
		text-align: center;
		margin: 32rpx 32rpx 0 32rpx;
	}
	.btn-order{
		width: calc(100% - 64rpx);
		height: 102rpx;
		line-height: 102rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		border: 1rpx solid #EEEEEE;
		font-size: 32rpx;
		color: #585F70;
		text-align: center;
		margin: 32rpx 32rpx 0 32rpx;
	}

</style>
